<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <WasmBuildNative>true</WasmBuildNative>
    <FeatureWasmPerfTracing>true</FeatureWasmPerfTracing>
    <WasmEnableThreads>true</WasmEnableThreads>
    <WasmEnablePerfTracing>true</WasmEnablePerfTracing>
    <NoWarn>$(NoWarn);CA2007</NoWarn> <!-- consider ConfigureAwait() -->
    <MonoDiagnosticsMock Condition="('$(MonoDiagnosticsMock)' == '') and ('$(Configuration)' == 'Debug' or '$(ArchiveTests)' == 'true')">true</MonoDiagnosticsMock>
  </PropertyGroup>
  <Import Project="..\DefaultBrowserSample.targets" />

  <ItemGroup>
    <WasmExtraFilesToDeploy Include="index.html" />
    <WasmExtraFilesToDeploy Include="main.js" />
    <WasmExtraFilesToDeploy Include="mock.js" Condition="'$(MonoDiagnosticsMock)' == 'true'"/>
    <!-- this option requires running dotnet-dsrouter and a real dotnet-trace client -->
    <WasmExtraConfig Condition="'$(MonoDiagnosticsMock)' != 'true'" Include="environmentVariables" Value='
{
  "MONO_LOG_LEVEL": "warning",
  "MONO_LOG_MASK": "all",
  "DOTNET_DiagnosticPorts": "ws://localhost:8088/diagnostics,suspend",
  "CI_TEST": "$(ArchiveTests)"
}' />
    <!-- this option requires compiling the runtime with /p:MonoDiagnosticsMock=true and also building this project with the same property-->
    <WasmExtraConfig Condition="'$(MonoDiagnosticsMock)' == 'true'" Include="environmentVariables" Value='
{
  "MONO_LOG_LEVEL": "warning",
  "MONO_LOG_MASK": "all",
  "DOTNET_DiagnosticPorts": "mock:./mock.js,suspend",
  "CI_TEST": "$(ArchiveTests)"
}' />
  </ItemGroup>

  <PropertyGroup>
    <RunAnalyzers>true</RunAnalyzers>
  </PropertyGroup>

  <!-- set the condition to false and you will get a CA1416 errors about calls to create DiagnosticCounter instances -->
  <ItemGroup Condition="true">
    <!-- TODO: some .props file that automates this.  Unfortunately just adding a ProjectReference to Microsoft.NET.WebAssembly.Threading.proj doesn't work - it ends up bundling the ref assemblies into the publish directory and breaking the app. -->
    <!-- it's a reference assembly, but the project system doesn't know that - include it during compilation, but don't publish it -->
    <ProjectReference Include="$(LibrariesProjectRoot)\System.Diagnostics.Tracing.WebAssembly.PerfTracing\ref\System.Diagnostics.Tracing.WebAssembly.PerfTracing.csproj" IncludeAssets="compile" PrivateAssets="none" ExcludeAssets="runtime" Private="false" />
  </ItemGroup>

  <Target Name="RunSample" DependsOnTargets="RunSampleWithBrowser" />
</Project>
